<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>示例 2</title>
    <style>
        #txt1{
            color: deepskyblue;
            font-size: 12px;
        }
        #box1{
            background:url("img/2.gif") repeat;
            background-size:100%;
            border: 1px   solid  red;
            width: 50px;
            height: 80px;
        }
        #txt2{
            color: deepskyblue;
            font-size: 12px;
        }
        #box2{
            background: url("img/2.gif")  no-repeat red;
            width: 100px;
            height: 50px;
            border: 1px solid red;
            background-size:cover;
        }
        #txt3{
            color: deepskyblue;
            font-size: 12px;
        }
        #box3{
            background: url("img/2.gif")  no-repeat;
            width: 100px;
            height: 50px;
            border: 1px solid red;
            background-size:contain;
        }
    </style>
</head>
<body>
<fieldset>
    <legend>background-size</legend>
    <div id="txt1">像素</div>
    <div id="box1"></div>
    <div id="txt2">cover</div>
    <div id="box2"></div>
    <div id="txt3">contain</div>
    <div id="box3"></div>
</fieldset>

</body>
</html>